{include file="public/header-static"/}
{include file="public/sidebar"/}
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader-0.1.5/webuploader.css">


<div id="main">
    {include file="public/header"/}
    <main class="main-content">
        <div class="container">
            <div class="page-header">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="#">首页</a>
                        </li>
                        <li class="breadcrumb-item active" aria-current="page">服务设置  </li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-body">
                            <form action="{:url('/service/serviceEdit')}" method="post" target="iframe_form" enctype="multipart/form-data" >

                                <input type="hidden" name="id"  class="form-control" value="{$info.id}">

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">用户ID</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="uid"  class="form-control" placeholder="用户ID" value="{$info.uid}" readonly style="cursor: no-drop;">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">姓名</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="name"  class="form-control"  placeholder="姓名" value="{$info.name}">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">手机号</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="mobile"  class="form-control"  placeholder="手机号" value="{$info.mobile}">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">企业名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="company"  class="form-control"  placeholder="企业名称" value="{$info.company}">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-1 col-form-label">上门地址</label>
                                    <div class="input-group col-sm-8">

                                        <select name="province" id="province"  class="form-control" style="width:33%;">
                                            <option value="">请选择省份</option>
                                            {volist name="province" id="vo"}
                                            <option value="{$vo.location_id}" {if $vo.location_id == $info.province}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select name="city" id="city"  class="form-control" style="width:33%;">
                                            <option value="">请选择城市</option>
                                            {volist name="city" id="vo"}
                                            <option value="{$vo.location_id}" {if $vo.location_id == $info.city}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select name="area" id="area"  class="form-control" style="width:33%;">
                                            <option value="">请选择地区</option>
                                            {volist name="area" id="vo"}
                                            <option value="{$vo.location_id}" {if $vo.location_id == $info.area}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                    </div>
                                </div>


                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">详细地址</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="location"  class="form-control"  placeholder="详细地址" value="{$info.location}">
                                    </div>
                                </div>


                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">上门时间</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="home_time"  class="form-control"  placeholder="上门时间" value="{$info.home_time}" style="cursor: default;background-color: #ffffff;" id="demoTest" readonly>
                                    </div>
                                </div>


                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">企业服务码</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="service_number"  class="form-control"  placeholder="企业服务码" value="{$info.service_number}">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">社群编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="resource_number"  class="form-control"  placeholder="社群编号" value="{$info.resource_number}">
                                    </div>
                                </div>


                                <button type="submit" class="btn btn-secondary">提交</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </main>

    {include file="public/footer"/}

    <script>
        function getNowFormatDate() {

            var date = new Date( );
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + date.getHours() + seperator2 + date.getMinutes()
                + seperator2 + date.getSeconds();
            return currentdate;
        }

        layui.use(['laydate'],function(){
            var laydate = layui.laydate;
            //时间选择器
            laydate.render({
                elem: '#demoTest'
                ,type: 'datetime'
                ,min: getNowFormatDate()
            });
        });





        $(function() {

            // 二级分类
            $('#level1').change(function () {
                var pid = $("#level1 option:selected").val();
                $("#level2").attr('disabled', true);
                $.post('{:url("/console/getResourceLevel")}', {'pid':pid}, function (res) {
                    if (res.code != 1) {
                        toastr.error(res.msg);
                    } else {
                        result = res.data;
                        var level2 = '<option value="">请选择二级分类</option>';
                        for (var i = 0; i < result.length; i++) {
                            var index = $.inArray(String(result[i].id), cateArr);
                            console.log(String(result[i].id), cateArr, index);
                            var dis = '';
                            var bgcolor = '';
                            if (index > -1) {
                                dis = 'disabled';
                                bgcolor = 'background-color:#d8d6d6';
                            }
                            level2 += '<option ' + dis + ' style="' + bgcolor + '" value=' + result[i].id + '>';
                            level2 += result[i].name;
                            level2 += '</option>';
                        }
                        $("#level2").text('');
                        $("#level2").append(level2);
                        $("#level2").attr('disabled', false);
                    }
                });
            });

            // 城市
            $('#province').change(function(){
                var pid = $("#province option:selected").val();
                $.ajax({
                    type:"post",
                    url:'{:url("/console/getCity")}',
                    data:{'pid':pid},
                    success:function(res){
                        if(res.code == 1){
                            result = res.data;
                            var strocity = '<option value="">请选择城市</option>';
                            for (var i = 0; i < result.length; i++) {
                                strocity += '<option value=' + result[i].location_id + '>';
                                strocity += result[i].name;
                                strocity += '</option>';
                            }
                            $("#city").text('');
                            $("#area").text('');
                            $("#area").append('<option value="">请选择地区</option>');
                            $("#city").append(strocity);
                        }else{
                            toastr.error(res.msg);
                        }
                    }
                })
            });

            // 地区
            $('#city').change(function(){
                var pid = $("#city option:selected").val();
                $.ajax({
                    type:"post",
                    url:'{:url("/console/getArea")}',
                    data:{'pid':pid},
                    success:function(res){
                        if(res.code == 1){
                            result = res.data;
                            var strocity = '<option value="">请选择地区</option>';
                            for (var i = 0; i < result.length; i++) {
                                strocity += '<option value=' + result[i].location_id + '>';
                                strocity += result[i].name;
                                strocity += '</option>';
                            }
                            $("#area").text('');
                            $("#area").append(strocity);
                        }else{
                            toastr.error(res.msg);
                        }
                    }
                })
            });
        });

    </script>

</div>